package com.leyou.upload.test;

import java.util.concurrent.TimeUnit;
import java.util.concurrent.locks.Lock;
import java.util.concurrent.locks.ReentrantLock;

public class JHKG {

    public static int count = 0;

    public static void main(String[] args) {

/*        for (int i = 0; i < 5; i++) {
            Thread a = new Thread(new Runnable() {
                private Lock lock = new ReentrantLock();

                @Override
                public void run() {
                    // 循环买票
                    for (int i = 0; i < 2; i++) {
                        // t1	t2
                        // 获取锁
                        lock.lock();
                        try {
                            Thread.sleep(50);
                            count++;
                            if (count > 10) {
                                break;
                            }

                        } catch (Exception e) {
                            e.printStackTrace();
                        }
                        System.out.println(count + (count != 10 ? "," : ""));
                        // 释放锁
                        lock.unlock();
                    }
                }
            });
            a.start();
        }
    }*/
        WindowTicketTask2 t = new WindowTicketTask2();
        for (int x = 0; x < 5; x++) {
            Thread thread = new Thread(t);
            thread.start();
        }
    }
}


